<template>
  <div class="app-container">
    <el-table
      v-loading="loading"
      :data="bomList"
      stripe="true"
      row-key="id"
      :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
    >
      <el-table-column prop="level" label="层级" :show-overflow-tooltip="true" width="160"></el-table-column>
      <el-table-column prop="name" label="物料编码" :show-overflow-tooltip="true" width="160"></el-table-column>
      <el-table-column prop="description" label="物料描述" :show-overflow-tooltip="true" width="100"></el-table-column>
      <el-table-column prop="qty" label="数量" align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="revision" label="版本" align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="current" label="状态" align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="type" label="类型" align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="policy" label="策略" align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="relationship" label="关系" align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="id" label="ID" align="center" :show-overflow-tooltip="true"></el-table-column>
      <el-table-column prop="parentId" label="parentID" align="center" :show-overflow-tooltip="true"></el-table-column>
    </el-table>
  </div>
</template>

<script>
import { bomListData } from "@/api/pms/material";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import IconSelect from "@/components/IconSelect";

export default {
  name: "Bom",
  components: { Treeselect, IconSelect },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 表格树数据
      bomList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        partId: undefined
      },
      // 表单参数
      form: {}
    };
  },
  created() {
    //24880.42681.12704.14821
    this.queryParams.partId = this.$route.params && this.$route.params.partId;
    this.getList();
  },
  methods: {
    /** 查询菜单列表 */
    getList() {
      this.loading = true;
      bomListData(this.queryParams).then(response => {
        this.bomList = this.handleTree(response.data, "id");
        this.loading = false;
      });
    }
  }
};
</script>
